﻿using System;
using cz.uhul.DSMLv2;


namespace cz.uhul.DSMLv2.Server.Sql
{



  public static partial class LdRequestServerExtension
  {




    public static LdAuthResponse Execute(this LdAuthRequest authReq)
    {

      return new LdAuthResponse(LdResultCodeEnum.AuthMethodNotSupported, "auth not implemented now", null);

      //try
      //{
      //  int result = 0;

      //  result += LdDatabase.Compare("cn=ldRead,cn=acl,cn=config", "member", authReq.Principal) ? 1 : 0;
      //  result += LdDatabase.Compare("cn=ldAdd,cn=acl,cn=config", "member", authReq.Principal) ? 2 : 0;
      //  result += LdDatabase.Compare("cn=ldDelete,cn=acl,cn=config", "member", authReq.Principal) ? 4 : 0;
      //  result += LdDatabase.Compare("cn=ldModify,cn=acl,cn=config", "member", authReq.Principal) ? 8 : 0;

      //  if (result > 0)
      //    return new LdAuthResponse(LdResultCodeEnum.Success, "aclBitMask[MOD,DEL,ADD,READ]:" + result.ToString(), null);

      //  else
      //    return new LdAuthResponse(LdResultCodeEnum.InsufficientAccessRights, "not permited to any LD operation", null);

      //}
      //catch (Exception e)
      //{
      //  //todo:LdDatabase.DeleteEntry(RootDSE, DistinguishedName);
      //  //or better rollback tran
      //  return new LdAuthResponse(LdResultCodeEnum.OperationsError, "authRequest failed for dn=" + authReq.Principal, e.Message);
      //}

    }


  }

}